#include "psearch.h"

int main( int argc, char *argv[]){

  int i;          
  int n;          // size of the array
  int ntds;	  // number of threads
  int keyid;   
  n = (argc>=2)    ? atoi(argv[1]) : NE_DEFAULT;	
  ntds = (argc>=3) ? atoi(argv[2]) : NTDS_DEFAULT;

  double *A = (double *) malloc( n * sizeof(double) );
  double key = 1.0/3.0 * n;
  printf("\tGenerate array A of size %d ( range (0, %d) ) and key %f\n", n, n-1, key);

  // initialize array values
  for(i=0;i<n;i++) A[i] = (double) i;  

  double tstart, tend;
  tstart = omp_get_wtime();
  keyid = omp_bsearch(&key, A, n, sizeof(A[0]), userComparOperator, ntds);
  tend =omp_get_wtime();

  printf("\n\tUsing %d threads\n", ntds);
  printf("\tThe id for the key is %d. It should be %d.\n", keyid, (int)key);
  printf("\tEllapsed time=%2.2g secs\n", tend - tstart);
  return 0;
}




	
 

	
	
